<template>
<div class="upsrc">
  <img :src="getUrl ? getUrl : this.url " >
</div>
</template>

<script>
import {buildImage} from '@/assets/js/ImageUtil'
export default {
  name: 'build-image',
  data() {
    return {
      url: require('../assets/images/upbtn.png')
    }
  },
  components: {},
  props: {
    imgPath: {
      type: String,
      default: ''
    },
    mode: {
      type: String,
      default: 'default'
    }
  },
  beforeCreate(){},
  beforeMount(){}, 
  mounted(){},
  methods: {},
  computed: {
    getUrl: function () {
      if(this.imgPath && this.imgPath.length > 0) {
        return buildImage(this.imgPath)
      } else {
        if(this.mode && this.mode === 'default') {
          this.url = require('../assets/images/default.png')
        }
      }
    }
  }
}
</script>

<style scoped>
.upsrc {
  position: relative;
  width: 140px;
  height: 140px;
  margin: 10px;
  display: flex;
  justify-content: center;
  align-items: Center;
  border: 1px solid #d9d9d9;
  border-radius: 3px;
  overflow: hidden;
}
.upsrc img {
  width: 100%;
}

</style>
